-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ulimited body parsing #1983
Conversation
@krizhanovsky Is this condition correct? If so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only one question and if there is no problem, then just comment why do we exepct body in the first skb and merge.
Regarding tfw_http_hm_control()
- we return from the function if the server is alive (not suspended) since we do not need to mark it alive with tfw_srv_mark_alive()
, so the code seems correct. This is an example why it's bad to write code without comments :)
it->frag = -1; | ||
|
||
/* Set starting position. */ | ||
r = ss_skb_find_frag_by_offset(it->skb, body_start, &it->frag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we expect to find start of the body in the first skb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not first skb. tfw_body_iter_init()
- Initializes iterator with data obtained during body parsing, we pass to this function pointer to start of the body and pointer to sk_buff
that holds the body or first chunks of the body. We use these pointers as starting point. If skb start
doesn't "contain" passed pointer body_start
error will be handled below. ss_skb_find_frag_by_offset()
finds index of the fragment that contains body_start
pointer.
This part is ok. However looks strange following condition if we take into account that
|
/* | ||
* Special case for 'auto' monitor: generate crc32 | ||
* from body of first response and store it into monitor. | ||
*/ | ||
if (!hm->crc32 && hm->auto_crc) { | ||
hm->crc32 = tfw_str_crc32_calc(body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tfw_str_crc32_calc is now unused, we can remove it from our code and tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer don't remove this function. Time to time we use crc32 for TfwStr
even for debug purposes and it useful to have such function.
If the response doesn't have body tempesta parses the body until the connection is closed, in this case need to update overall body size and don't make chunks. -Added error handling to `tfw_cache_h2_copy_body()`
There is copule of places where need to iterate over http message body. For this purposes has been added body iterator. Just initialize iterator and chunk using `tfw_body_iter_init()` with error handling. Use `TFW_BODY_ITER_WALK` macro for walking over the body as TfwStr. tfw_apm_hm_srv_alive(): Calculate crc32 for message body using body itertor instead of looping invalid TfwStr.
If the response doesn't have body tempesta parses the body until the connection is closed, in this case need to update overall body size and don't make chunks.
-Added error handling to
tfw_cache_h2_copy_body()